package com.summary.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.github.pagehelper.PageHelper;
import com.ruoyi.common.core.page.PageDomain;
import com.summary.domain.dto.TbSummaryDto;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.summary.domain.TbSummary;
import com.summary.service.ITbSummaryService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 日报业务Controller
 * 
 * @author ruoyi
 * @date 2023-12-15
 */
@RestController
@RequestMapping("/summary/summary")
public class TbSummaryController extends BaseController
{
    @Autowired
    private ITbSummaryService tbSummaryService;

    /**
     * 查询日报业务列表
     */
    @PreAuthorize("@ss.hasPermi('summary:summary:list')")
    public TableDataInfo list(TbSummary tbSummary)
    {
        System.out.println("assa");
        startPage();
        List<TbSummary> list = tbSummaryService.selectTbSummaryList(tbSummary);
        return getDataTable(list);
    }

    /**
     * 导出日报业务列表
     */
    @PreAuthorize("@ss.hasPermi('summary:summary:export')")
    @Log(title = "日报业务", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbSummary tbSummary)
    {
        List<TbSummary> list = tbSummaryService.selectTbSummaryList(tbSummary);
        ExcelUtil<TbSummary> util = new ExcelUtil<TbSummary>(TbSummary.class);
        util.exportExcel(response, list, "日报业务数据");
    }

    /**
     * 获取日报业务详细信息
     */
    @PreAuthorize("@ss.hasPermi('summary:summary:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tbSummaryService.selectTbSummaryById(id));
    }

    /**
     * 新增日报业务
     */
    @PreAuthorize("@ss.hasPermi('summary:summary:add')")
    @Log(title = "日报业务", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbSummary tbSummary)
    {

        return toAjax(tbSummaryService.insertTbSummary(tbSummary));
    }

    /**
     * 修改日报业务
     */
    @PreAuthorize("@ss.hasPermi('summary:summary:edit')")
    @Log(title = "日报业务", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbSummary tbSummary)
    {
        return toAjax(tbSummaryService.updateTbSummary(tbSummary));
    }

    /**
     * 删除日报业务
     */
    @PreAuthorize("@ss.hasPermi('summary:summary:remove')")
    @Log(title = "日报业务", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tbSummaryService.deleteTbSummaryByIds(ids));
    }





}
